package com.rc.saas.mini.service.help;

import com.rc.saas.mini.mapper.help.UserGuideMapper;
import com.rc.saas.mini.model.help.UserGuide;
import com.rc.saas.mini.model.help.UserGuideExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author wangzhengwei
 * @create 2021/1/6
 */
@Service
public class UserGuideServiceImpl implements UserGuideService {
    @Autowired
    private UserGuideMapper userGuideMapper;

    @Override
    public UserGuideMapper getMapper() {
        return userGuideMapper;
    }

    @Override
    public List<UserGuide> selectFirstByTenantCode(String tenantCode) {
        UserGuideExample example = new UserGuideExample();
        example.createCriteria().andTenantCodeEqualTo(tenantCode).andGuideTypeEqualTo("0");
        example.setOrderByClause("sort");
        userGuideMapper.selectByExample(example);
        return userGuideMapper.selectByExample(example);
    }

    @Override
    public List <UserGuide> selectSecondByFirst(Long userGuideId, String tenantCode) {
        UserGuideExample example = new UserGuideExample();
        example.createCriteria().andTenantCodeEqualTo(tenantCode).andParentIdEqualTo(userGuideId).andGuideTypeEqualTo("1");
        example.setOrderByClause("sort");
        userGuideMapper.selectByExample(example);
        return userGuideMapper.selectByExample(example);
    }
}
